package rpc

import (
	"fmt"

	"gitee.com/go-course/go11/vblog/apps/comment"
	"gitee.com/go-course/go11/vblog/conf"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func NewClient(c conf.Grpc) *Client {
	fmt.Println(c.Address())
	conn, err := grpc.Dial(c.Address(), grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		panic(err)
	}
	return &Client{
		c: conn,
	}
}

type Client struct {
	c *grpc.ClientConn
}

// comment 模块的rpc服务
func (c *Client) Comment() comment.RpcClient {
	return comment.NewRpcClient(c.c)
}
